package cn.chenhongchao.zhaobiaopingtai.controller;


import cn.chenhongchao.zhaobiaopingtai.common.api.CommonPage;
import cn.chenhongchao.zhaobiaopingtai.common.api.CommonResult;
import cn.chenhongchao.zhaobiaopingtai.dto.SupplierLoginData;
import cn.chenhongchao.zhaobiaopingtai.dto.param.TenderFileListData;
import cn.chenhongchao.zhaobiaopingtai.entity.Tender;
import cn.chenhongchao.zhaobiaopingtai.service.ISupplierLpginDataService;
import cn.chenhongchao.zhaobiaopingtai.service.ITenderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "供应商首页信息模块", tags = "供应商首页信息接口")
@RestController
@CrossOrigin
@RequestMapping("/supplierLogin")
public class SupplierLoginController {

            @Resource
            private ITenderService tenderService;

            @Resource
            private ISupplierLpginDataService supplierLpginDataService;

            @Resource
            protected BCryptPasswordEncoder bCryptPasswordEncoder;



//            @RequestMapping(value = "/getSupLogin",method = RequestMethod.POST)
//            public CommonResult getCurrentUserLogin(String supName,String supPass){
//                    Boolean flag =  supplierLpginDataService.loginPhone(supName,supPass);
//                    if (flag){
//                        return CommonResult.success(supplierLpginDataService.getUserByPhone(supName));
//                    }
//                return CommonResult.failed("登陆失败！");
//            }

        @ApiOperation(value = "分页中标列表", notes = "分页中标列表")
        @RequestMapping(value = "/tenderWinList",method = RequestMethod.POST)
        public CommonResult getTenderWinList(Integer pageNum,Integer pageSize) {
            return  CommonResult.success(CommonPage.restPage(tenderService.getList2(pageNum, pageSize)));
        }





        @ApiOperation(value = "分页招标列表", notes = "分页招标列表")
        @RequestMapping(value = "/tenderFileList",method = RequestMethod.POST)
        public CommonResult getTenderFileListFn(Integer pageNum, Integer pageSize, @RequestBody TenderFileListData tenderFileListData) {
                Integer categorynameIndex = tenderFileListData.getCategorynameIndex();
                String tenderName = tenderFileListData.getTenderName();
            return  CommonResult.success(CommonPage.restPage(tenderService.getListzhaobiao2(pageNum, pageSize,categorynameIndex, tenderName)));
        }


        @ApiOperation(value = "招标文件详细信息", notes = "招标文件详细信息")
        @RequestMapping(value = "/getTenderFileByCode",method = RequestMethod.POST)
        public CommonResult getTenderFileByCode(Integer tenderFileCode) {

            return  CommonResult.success(tenderService.getTenderByCode(tenderFileCode));

        }
}
